package com.ming;

import com.alibaba.druid.pool.DruidDataSource;
import com.ming.config.ServerConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@EnableCaching
public class Demo2Application {

    @Bean
//    属性注入为宽松绑定  驼峰、下划线、横线
    @ConfigurationProperties(prefix = "datasource")
    public DruidDataSource druidDataSource(){
        DruidDataSource ds = new DruidDataSource();
        ds.setDriverClassName("com.mysql.jdbc.Driver");
        return ds;
    }
    public static void main(String[] args) {
        ConfigurableApplicationContext ctx = SpringApplication.run(Demo2Application.class, args);
        ServerConfig ServerConfigBean = ctx.getBean(ServerConfig.class);
        DruidDataSource DruidDataSourceBean = ctx.getBean(DruidDataSource.class);


    }

}
